package prototype.demo.copyPlus;

import prototype.demo.bean.Bean1;
import prototype.demo.bean.Bean2;

public class Bean3 implements Cloneable{

    private Bean1 bean1;
    private Bean2 bean2;

    public Bean1 getBean1() {
        return bean1;
    }

    public void setBean1(Bean1 bean1) {
        this.bean1 = bean1;
    }

    public Bean2 getBean2() {
        return bean2;
    }

    public void setBean2(Bean2 bean2) {
        this.bean2 = bean2;
    }

    public Bean3(Bean1 bean1, Bean2 bean2){
        this.setBean1(bean1);
        this.setBean2(bean2);
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        Bean3 clone = (Bean3) super.clone();
        clone.bean1 = (Bean1) clone.getBean1().clone();
        clone.bean2 = (Bean2) clone.getBean2().clone();
        return clone;
    }

    @Override
    public String toString() {
        return "Bean3{" +
                "bean1=" + bean1 +
                ", bean2=" + bean2 +
                '}';
    }
}
